﻿using Microsoft.Extensions.Diagnostics.HealthChecks;
using Stickerwall.Common;

namespace Stickerwall.WebAPI.HealthChecks
{
    public sealed class HealthCheckFull(IDataAccessor dataAccessor) : IHealthCheck
    {
        
        public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = new CancellationToken())
        {
            var (succeeded, reason) = await dataAccessor.CheckDatabaseTableAsync(cancellationToken);
            return succeeded ? HealthCheckResult.Healthy() : HealthCheckResult.Unhealthy(reason);
        }
    }
}
